import { defineStore } from 'pinia';
 interface userData{
      id:string,
      username:string
    }
export const useUserStore = defineStore('user', {
  
  state: () => ({
    user: null as userData | null,
  }),
  getters: {
    getUser: (state) => state.user,
    isAuthenticated: (state) => !!state.user,
  },
  actions: {
   
    setUser(newUser:userData) {
      this.user = newUser;
    },
    logout() {
      this.user = null;
      // 可以在这里执行其他清理操作
    },
  },
});